﻿/**
<code>
  <author name="Zealic" email="zealic(at)gmail.com" type="Creator"/>
</code>
**/
using System;


namespace Zealib.Template
{
    public class DelegateVariableSource : IVariableSource
    {
        public DelegateVariableSource(Func<string, string> resolver)
        {
            if(resolver == null) throw new ArgumentNullException("resolver");
            Resolver = resolver;
        }

        public Func<string, string> Resolver
        {
            get;
            private set;
        }

        public virtual string Resolve(string expression)
        {
            if (expression == null) throw new ArgumentNullException("expression");
            return Resolver(expression);
        }

    }
}
